Staged Alerts
Volume Number: 2
Issue Number: 7
Column Tag: Basic School
ResEdit Creates Staged Alerts for Basic
By Dave Kelly, Editorial Board
Alerts and MS Basic
Let's talk about how to set up your own Alerts. For any of you that are not sure
what alerts are, just pull down the 'About' menu from just about any application. The
dialog box in an 'About' menu item is a form of an alert that usually gives information
about who wrote the application. For Macintosh programmers who are experienced in C
or Pascal or other languages with Toolbox access, Alerts are probably old hat. MS
BASIC programs have traditionally been using one of four regular windows for Alerts
with the simulated Alert itself being controlled by programming within the BASIC
program instead of by the Toolbox.
User Modified Programs
One feature not found on other computers is the ability to modify or customize
the text, menus etc. after the program is written. This ability is only found in
programs that use resources to store the menu, window, dialog or alert information.
Therefore, since you must set up the information inside the BASIC program when using
MS Basic, you must rewrite that section of BASIC code in order to change the
information. For example, to change a menu from English to French would require that
you translate each MENU command to French and modify each program line. That's not
too hard to do, and not necessary very often, but still a disadvantage over other Mac
languages.
How many times have you tried to figure out what size window you need in your
program and have to guess at what the window coordinates are on the screen and then
guess where the controls will be inside the window? What a pain. I tried to help out
several issues of MacTutor back with the Rectangle Sizer program. That was ok, but
you still had to use some trial and error till you got everything to look just right. The
elegant solution is not to try to create your own custom windows in BASIC, but to create
custom Alerts which may be used as often as desired, created much easier using
ResEdit. (For a good discussion of Resource Editors, see Joel West's column in the May,
1986 MacTutor.)
CLR ToolLib Gives Access to Alert Resources
MS BASIC alone still has the limitation of having to set up Alerts as windows and
simulate Alerts in the windows from Basic. Using the CLR ToolLib, Alerts are called as
easily in BASIC as they are in other Toolbox Languages (C, Pascal, etc). Any language
which has access to the Toolbox commands can use this column to help them understand
Alerts better.
Alerts are probably one of the simplest routines to use. In most programs, you
have to process the event in order to tell what selections are made. This is true when
you set up your own dialogs (as you must do with MS BASIC). By using Alerts, you let
the Toolbox ROM do part of the work for you. The toolbox automatically tracks the
movement of the mouse for you and checks to see what controls or edit fields have been
accessed.
There are three major kinds of Dialogs:
(1) Alerts
(2) Modal Dialogs
(3) Modeless Dialogs
The lowest level is Alerts, normally used to display error messages or other
information. The Alert is always front-most on the screen and the only action which is
allowed, takes place in the dialog box. The next level of dialogs are called 'modal dialogs'.
In this 'mode', the dialog box will respond to the mouse and the keyboard. The modal
dialog also remains frontmost on the screen and the user may dismiss the dialog with
the keyboard or the mouse. 'Modeless dialogs' are dialogs which the user may move
around on the screen, has a go-away box, and the user can activate other windows
(bring to the front). This is the mode supported by MS BASIC except that MS BASIC
can't save a set dialog as a resource for repeated use. Instead you have to dedicate one of
MS BASIC's four windows (only four windows may be open at one time) to be the desired
dialog. [Note: ResEdit is available on the Utilities Disk. See the MacTutor mail order
store for information. -Ed.]
How to Use ResEdit
Before we get into how to call the Alerts using CLR Libraries and MS BASIC, let's
set up our own custom Alert file using ResEdit. ResEdit is considered the easiest way to